import pytest
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from time import sleep

base_url='http://jxc.b2zg.cn/#/login'
class TestBuer():
    def setup_method(self):
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()

    def teardown_method(self):
        sleep(10)
        self.driver.quit()  # 退出浏览器

    def test_buer(self):
        self.driver.get(base_url)
        WebDriverWait(self.driver,10,0.5).until(EC.presence_of_all_elements_located((By.CLASS_NAME,'el-input__inner')))[0].send_keys('15042844706')
        sleep(2)
        WebDriverWait(self.driver, 10, 0.5).until(EC.presence_of_all_elements_located((By.CLASS_NAME, 'el-input__inner')))[1].send_keys("admin123.")
        WebDriverWait(self.driver, 10, 0.5).until(EC.presence_of_element_located((By.XPATH, '//*[@id="app"]/div/div[1]/div[2]/div[1]/div[2]/form/button/span/b'))).click()
        sleep(2)

        #销售
        #WebDriverWait(self.driver,10,0.5).until(EC.presence_of_element_located((By.XPATH,'//*[@id="app"]/div/div[1]/li[1]/a/span/b'))).click()
        #sleep(2)
        #网页订单
        #WebDriverWait(self.driver,10,0.5).until(EC.presence_of_element_located((By.XPATH,'//*[@id="app"]/div/div[1]/li[1]/div/div/div/ul/li[1]/a'))).click()
        #财务
        WebDriverWait(self.driver,10,0.5).until(EC.presence_of_element_located((By.XPATH,'//*[@id="app"]/div/div[1]/li[4]/a/span/b'))).click()
        sleep(3)
        #客户对账单
        WebDriverWait(self.driver,10,0.5).until(EC.presence_of_element_located((By.XPATH,'//*[@id="app"]/div/div[1]/li[4]/div/div/div[1]/ul/li[1]/a'))).click()
        sleep(3)
        #日常收入
        WebDriverWait(self.driver,10,0.5).until(EC.presence_of_element_located((By.XPATH,'//*[@id="app"]/div/div[1]/li[4]/div/div/div[2]/ul/li[1]/a[1]'))).click()
        sleep(3)
        #返回首页
        #WebDriverWait(self.driver,10,0.5).until(EC.presence_of_all_elements_located((By.CLASS_NAME,'tags-view-item')))[0].click()
        #sleep(3)
        win1 = 'window.scrollBy(0,500)'
        self.driver.execute_script(win1)
        sleep(7)









